@extends(config('admin.systems.layout_blade'))

@section('content')
    <div class="row">
        <div class="col-md-12">
            <div class="box">
                <div class="box-header with-border">
                    <h3 class="box-title">{{ get_value(config('admin.systems.document_type_list', []), $documentType, '文档') }}管理</h3>


                </div>

                <!-- /.box-header -->
                <div class="box-body">
                    <div class="mailbox-controls">
                        <!-- Check all button -->

                        <div class="btn-group pull-left">
                            @permission('admin-portal-'.$documentType.'-delete')
                            <button type="button" class="btn btn-danger btn-sm ajax-post confirm" data-url="{{ get_admin_url('portal/'.$documentType.'/delete') }}" data-target-form="ids" data-prompt-information="确定要删除选中的数据吗？"><i class="fa fa-trash-o"></i></button>
                            @endpermission

                            @permission('admin-portal-'.$documentType.'-set-status')

                            <button type="button" data-url="{{ get_admin_url('portal/'.$documentType.'/setStatus', ['status'=>-1]) }}" class="btn btn-danger btn-sm ajax-post confirm" title="禁用后前台不显示" data-target-form="ids" data-prompt-information="确定要禁用选中的该文档吗？">禁用</button>

                            <button type="button" data-url="{{ get_admin_url('portal/'.$documentType.'/setStatus', ['status'=>99]) }}" class="btn btn-success btn-sm ajax-post confirm" title="启用后前台正常显示" data-target-form="ids" data-prompt-information="确定要启用选中的该文档吗？">启用</button>

                            @endpermission

                            <button type="button" class="btn btn-default btn-sm" title="上一步" onclick="window.history.go(-1);"><i class="fa fa-reply"></i></button>
                            <button type="button" class="btn btn-default btn-sm" title="下一步" onclick="window.history.forward()"><i class="fa fa-share"></i></button>

                            @permission('admin-portal-'.$documentType.'-edit')
                            <a href="{{ get_admin_url('portal/'.$documentType.'/edit', ['id'=>0]) }}?category_id={{ get_value($search, 'categoryId', 0) }}" class="btn btn-success btn-sm checkbox-toggle"><i class="fa fa-plus"></i></a>
                            @endpermission



                            <button type="button" class="btn btn-primary btn-sm" onclick="window.location.reload();"><i class="fa fa-refresh"></i></button>
                        </div>

                        <div class="row pull-left" style="margin-left: 10px;">
                            {{ Form::open(['url'=>get_admin_url('portal/'.$documentType), 'method'=>'get', 'class'=>'form-horizontal']) }}

                                <div class="col-xs-5">
                                    <select name="search[category_id]" id="" class="form-control input-sm">

                                        <option value="0" @if(get_value($search, 'categoryId', 0) == 0) selected @endif>--请选择--</option>
                                        {!! get_select_tree($categoryList, get_value($search, 'categoryId', 0), $categoryNotAllowIdList) !!}
                                    </select>
                                </div>

                                <div class="col-xs-5">
                                    <input type="text" class="form-control input-sm" name="search[keywords]" placeholder="请输入标题关键字……" value="{{ get_value($search, 'keywords', null) }}">
                                </div>

                                <div class="col-xs-2">
                                    <button type="submit" class="btn btn-primary btn-sm"><i class="fa fa-search"></i></button>
                                </div>
                            {!! Form::close() !!}
                        </div>


                        <div class="pull-right">
                            {{ $data->currentPage() }}-{{ $data->lastPage() }}/{{ $data->total() }}
                            <div class="btn-group">
                                <a href="{{ $data->previousPageUrl()  ? : 'javascript:void(0)' }}" type="button" class="btn btn-default btn-sm" {{ $data->previousPageUrl() ? '' : 'disabled' }}><i class="fa fa-chevron-left"></i></a>
                                <a href="{{ $data->nextPageUrl() ? : 'javascript:void(0)' }}" type="button" class="btn btn-default btn-sm" {{ $data->nextPageUrl() ? '' : 'disabled' }}><i class="fa fa-chevron-right"></i></a>
                            </div>
                        </div>
                    </div>

                    <table class="table table-bordered">
                        <tr>
                            <th style="width: 10px"><input type="checkbox" name="ids" value="0" class="check-all"></th>
                            <th>编号</th>
                            <th>封面</th>
                            <th>标题</th>
                            <th>所属栏目</th>
                            <th>来源</th>
                            <th>点击量</th>
                            <th>状态</th>
                            <th>发布时间</th>
                            <th>创建时间</th>
                            <th style="width: 160px;">操作</th>
                        </tr>
                        @foreach ($data as $key=>$value)
                            <tr>
                                <td>
                                    <input type="checkbox" name="ids[]" class="ids" value="{{ $value->id }}">
                                </td>
                                <td>{{ $value->id }}</td>
                                <td><img src="{{ get_upload_url($value->cover) }}" class="img-responsive" width="120" alt=""></td>
                                <td>{{ $value->title }}</td>
                                <td>{{ $value->category->title }}</td>
                                <td>{{ get_value($sourceList, $value->source_id, '无') }}</td>
                                <td>{{ $value->click }}</td>
                                <td>{{ get_value(config('admin.systems.document_status_list'), $value->status, '未知')}}</td>
                                <td>{{ $value->fixed_release_time }}</td>
                                <td>{{ $value->created_at }}</td>
                                <td>
                                    @permission('admin-portal-'.$documentType.'-edit')
                                    <a href="{{ get_admin_url('portal/'.$documentType.'/edit', ['id'=>$value->id]) }}" class="btn btn-success btn-sm"><i class="fa fa-edit"></i></a>
                                    @endpermission
                                    @permission('admin-portal-'.$documentType.'-delete')
                                    <a href="{{ get_admin_url('portal/'.$documentType.'/delete', ['ids'=>$value->id]) }}" class="btn btn-danger btn-sm ajax-get confirm" data-prompt-information="确定要删除（{{ $value->title }}）该文档吗？"><i class="fa fa-trash-o"></i></a>
                                    @endpermission

                                    @permission('admin-portal-'.$documentType.'-set-status')
                                        @if($value->status == 99)
                                            <a href="{{ get_admin_url('portal/'.$documentType.'/setStatus', ['status'=>-1, 'ids'=>$value->id]) }}" class="btn btn-danger btn-sm ajax-get confirm" title="禁用后前台不显示" data-prompt-information="确定要禁用（{{ $value->title }}）该文档吗？">禁用</a>
                                        @elseif($value->status == -1)
                                            <a href="{{ get_admin_url('portal/'.$documentType.'/setStatus', ['status'=>99, 'ids'=>$value->id]) }}" class="btn btn-success btn-sm ajax-get confirm" title="启用后前台正常显示" data-prompt-information="确定要启用（{{ $value->title }}）该文档吗？">启用</a>
                                        @endif
                                    @endpermission
                                </td>
                            </tr>
                        @endforeach
                    </table>
                </div>

                <!-- /.box-body -->
                <div class="box-footer clearfix">
                    {{ $data->links() }}
                </div>
            </div>
            <!-- /.box -->
        </div>
    </div>
@endsection